package mytest.wd;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test4 {

    public static void main(String[] args) {
        String phone = "01739230579";
        System.out.println(judgePhone(phone));
    }

    public static boolean judgePhone(String phone) {
        if (StringUtils.isBlank(phone)) {
            return false;
        }
        if (!isNumeric(phone)) {
            return false;
        }
        if (phone.startsWith("0")) {
            phone = phone.substring(1);
        } else if (phone.startsWith("234")) {
            phone = phone.substring(3);
        }
        if (phone.length() != 10) {
            return false;
        }
        return true;
    }

    public static boolean isNumeric(String str) {
        Pattern compile = Pattern.compile("[0-9]*");
        Matcher isNum = compile.matcher(str);
        return isNum.matches();
    }

}
